﻿//--------------------------------------------------------------------------
// 
//  Copyright (c) Chili Software.  All rights reserved. 
// 
//  File: PersistBehaviours.cs
//
//  Description: Apply special persist behaviour on persistent properties.
// 
//--------------------------------------------------------------------------

using System;

namespace Chili.Opf3
{
	/// <summary>
	/// The member of this enumeration mark and enhance properties with special behaviour
	/// applied during the save process of a persistent object.
	/// </summary>
	/// <remarks>
	/// This enumeration is used to mark properties with special persisting behaviour. It
	/// allows to control the persisting behaviour on properties during insert and update operations of 
	/// the persistent object. DontInsert means, for example, that the value of the property is not 
	/// inserted during an insert operation of the persistent object.
	/// </remarks>
	/// <example>
	///     The following example shows a property that is only saved during an insert of the persistent object.
	///     The <see cref="FieldAttribute">FieldAttribute</see> is used to connect a
	///     property with a field of the entity. For additional information check out the 
	///     documentation of the <see cref="FieldAttribute">FieldAttribute</see> or the
	///     <see cref="PersistentAttribute">PersistentAttribute</see>.
	///     <code lang="CS">
	/// [Persistent("USER")]
	/// public class User
	/// {
	///     private string _name = null;
	///     
	///     [Field("NAME", PersistBehaviours = PersistBehaviours.DontUpdate)]
	///     public string Name
	///     {
	///         get { return _name; }
	///         set { _name = value; }
	///     }
	///     
	///     // ... Other properties and fields.
	/// }
	///     </code>
	/// </example>
	[Serializable]
	[Flags]
	public enum PersistBehaviours
	{
		/// <summary>
		/// A property marked with this flag is always persisted. It does not matter if the
		/// persistent is inserted or updated in the storage. This is the default behaviour of a
		/// property.
		/// </summary>
		None = 0,
		/// <summary>
		/// A property marked with this flag is not inserted. If the persistent object is updated this
		/// property is also updated.
		/// </summary>
		DontInsert = 1,
		/// <summary>
		/// A property marked with this flag is not updated. If the persistent object is inserted this
		/// property is also inserted.
		/// </summary>
		DontUpdate = 2
	}
}
